package com.eoekun.dashboard.model;


import java.io.Serializable;
import com.alibaba.fastjson.JSON;

/**
 * 分页查询父类
 * 
 * @ClassName: BaseDomain
 * @author chenkun
 * @date 2016年11月20日 上午12:10:27
 */
public class BaseDomain implements Serializable {

    private static final long serialVersionUID = -4131930030514594359L;

    /**
     * 开始页码
     */
    private int page;
    /**
     * 分页量
     */
    private int rows;
    /**
     * id asc , time desc
     */
    private String orderByClause;
    
    /**
     * 强制清空字段
     */
    private String forceNullField;

    public boolean isValid() {
        if (page < 1 || rows < 1) {
            page = 1;
            rows = 10;
        }
        return true;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getStart() {
        isValid();
        return (page - 1) * rows;
    }

    public String getOrderByClause() {
        return orderByClause;
    }

    public void setOrderByClause(String orderByClause) {
        this.orderByClause = orderByClause;
    }

    public String getForceNullField() {
        return forceNullField;
    }

    public void setForceNullField(String forceNullField) {
        this.forceNullField = forceNullField;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }



}
